package com.wunong.smart.collection.domain.model;

import com.wunong.smart.collection.client.enums.CollectionStatusEnum;
import com.wunong.smart.domain.platform.common.BizSource;
import com.wunong.smart.domain.platform.entify.BaseModel;
import com.wunong.smart.domain.platform.entify.User;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Objects;

/**
 * 收藏Domain
 *
 * @author create by zealot.zt
 */
@Getter
@Setter
@ToString(callSuper = true)
public class CollectionDomain extends BaseModel {

    /**
     * 业务来源信息
     */
    private BizSource source;

    /**
     * 收藏用户信息
     */
    private User user;

    /**
     * 收藏状态
     */
    private CollectionStatusEnum statusEnum;

    /**
     * 收藏类型
     */
    private String collectType;

    public static CollectionDomain of() {
        return new CollectionDomain();
    }

    public static CollectionDomain ofInitial() {
        CollectionDomain domain = of();
        domain.setStatusEnum(CollectionStatusEnum.INIT);
        return domain;
    }

    public Long getUserId() {
        return Objects.nonNull(user) ? user.getIdLong() : null;
    }

    /**
     * 是否为收藏中
     *
     * @return
     */
    public boolean isCollecting() {
        return statusEnum == CollectionStatusEnum.COLLECTING;
    }

    /**
     * 是否已取消收藏
     *
     * @return
     */
    public boolean isCanceled() {
        return statusEnum == CollectionStatusEnum.CANCELED;
    }

}
